<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css">
<link rel="stylesheet" href="skin/form.css">
<link rel="stylesheet" href="skin/btn.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body ontouchstart>
<div id="main" class="box-ver box"> 
  <div id="header">
  	<div class="title">
  		<span class="l icon back" ontouchstart="zy_touch('act')" onclick="uexWindow.close(-1);"></span>
		<span class="txt">修改登录密码</span>
	</div>
  </div>
  
  <div id="content">
	<div class="form">
    	<div class="items">
            <div class="item box box-hor">
            	<div class="label">原密码:</div>
            	<div class="txt">
            		<input type="password" name="opassword" id="opassword" maxlength="20"  placeholder="请输入4位数以上原密码" />
				</div>
            </div>
			<div class="item box box-hor">
            	<div class="label">新密码:</div>
            	<div class="txt">
            		 <input type="password" name="npassword" id="npassword" maxlength="20"  placeholder="请输入4位数以上新密码" />
				</div>
            </div>
			<div class="item box box-hor">
            	<div class="label">确认:</div>
            	<div class="txt">
            		  <input type="password" name="cnpassword" id="cnpassword" maxlength="20"  placeholder="请重输一遍新的密码" />
				</div>
            </div>
			
        </div>
	</div>

      <div class="btn">
       <div class="button" ontouchstart="zy_touch('')" onclick="post();">确定修改</div>
      </div>
    </form>
  </div>

</div>
</body>
<script>
    	zy_init();
		var Status=false;
		function post(){
			
			if(Status){
				return false;//禁止重复提交
			}
										
			var oPassword = $$("opassword").value;
			if(oPassword.length<4){
				uexWindow.alert('', '请填写4位数以上的原密码', '关闭');return false;
			}
			var nPassword = $$("npassword").value;
			if(nPassword.length<4){
				uexWindow.alert('', '请填写4位数以上的新密码', '关闭');return false;
			}
			if(oPassword==nPassword){
				uexWindow.alert('', '新密码不能跟原密码一样', '关闭');return false;
			}
			var cnPassword = $$("cnpassword").value;
			if(cnPassword==''){
				uexWindow.alert('', '请输入确认密码', '关闭');return false;
			}
			if(nPassword!=cnPassword){
				uexWindow.alert('', '确认密码与新密码不一致', '关闭');return false;
			}
			
			uexWindow.toast(1, 5, '提交中...', 0);
			
			var url=app_path+'index.php?m=iapp&c=user&a=editpwd&userid='+localStorage['u_id'];
			uexXmlHttpMgr.open(1,'post',url,"8000");
			uexXmlHttpMgr.setPostData(1,'0','userid',localStorage['u_id']);
			uexXmlHttpMgr.setPostData(1,'0','opassword',oPassword);
			uexXmlHttpMgr.setPostData(1,'0','npassword',nPassword);
			uexXmlHttpMgr.send(1);
			Status=true;
			
								
			
		}
		
		window.uexOnload = function(type){
			if (!type) {
				uexXmlHttpMgr.onData = function(opId, status, data){
					if(status==1){
						Status=false;
						uexXmlHttpMgr.close(opId);
						uexWindow.closeToast();
						data=JSON.parse(data);//把返回的字符转对象
						if(data['success']=='NODATA'){
							uexWindow.alert('','输入错误，请重试','关闭');							
						}else if(data['success']=='PASSERROR'){
							uexWindow.alert('','原密码输入不正确','关闭');							
						}else if(data['success']=='PASSLEN'){
							uexWindow.alert('','请输入4位以上的新密码','关闭');
						}else if (data['success'] == 'OK'){
							localStorage['u_acctoken']=data['acctoken'];
							uexWindow.confirm('密码修改成功','下次请使用新密码进行登录',['确定','关闭'])
							uexWindow.cbConfirm = function(opId,dataType,data){									
								uexWindow.close(-1);
							}
						}else{
							uexWindow.alert('','新密码设置失败','关闭');
						}
					}else if(status==-1){
						uexXmlHttpMgr.close(opId);
						Status=false;
						uexWindow.alert('','提交超时!','关闭');
					}
				}
				//提交结束
			}
		}
    </script>
</html>